package com.wootion.dizhi.controller;

import com.wootion.dizhi.entity.MethodEnumeration;
import com.wootion.dizhi.response.Result;
import com.wootion.dizhi.service.ResourceEstimationService;
import com.wootion.dizhi.vo.Condition;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 资源量估算(方法列举选用，通过计算得出资源量数据)
 */
@Api(tags = "资源量估算")
@RestController
@RequestMapping("/resourceEstimation")
public class ResourceEstimationController {
    @Resource
    private ResourceEstimationService resourceEstimationService;
    /**
     * 添加方法列举选用
     * @return
     */
    @ApiOperation("添加方法列举选用")
    @PostMapping("/insert")
    public Result insert(@RequestBody @Validated MethodEnumeration methodEnumeration){
        return resourceEstimationService.insert(methodEnumeration);
    }

    /**
     * 通过计算得出资源量数据
     * @return
     */
    @ApiOperation("通过计算得出资源量数据")
    @PostMapping("/list")
    public Result list(@RequestBody Condition condition){
        return resourceEstimationService.list(condition);
    }

    /**
     * 根据id查询
     * @return
     */
    @ApiOperation("根据id查询")
    @GetMapping("/findById")
    public Result findById(@RequestParam(value = "id")String id){
        return resourceEstimationService.findById(id);
    }

    /**
     * 根据id删除
     * @return
     */
    @ApiOperation("根据id删除")
    @DeleteMapping("/deleteById")
    public Result deleteById(@RequestParam(value = "id")String id){
        return resourceEstimationService.deleteById(id);
    }

    /**
     * 更新方法列举选用
     * @return
     */
    @ApiOperation("更新方法列举选用")
    @PutMapping("/update")
    public Result update(@RequestBody MethodEnumeration methodEnumeration){
        return resourceEstimationService.update(methodEnumeration);
    }

}
